package com.platform.qujia.enums;

import java.util.HashMap;

/**
 * @date 2023/10/8
 */
public enum RechargeTypeEnum {

    MANUAL_ADD("imp","手动充值"),
    WX_RECHARGE("wx","微信充值"),
    CDK("cdk","车队卡"),
    DKQ("dkq","实体卡"),
    SUPER_ONLINE("super_online","超级会员"),
    POS_RECHARGE("pos","移动支付"),
    DKQ_XJ("dkqxj","实体现金"),
    DKQ_WX_POS("dkqwxpos","实体移动"),
    ;

    private final String key;
    private final String name;

    RechargeTypeEnum(String key, String name) {
        this.key = key;
        this.name = name;
    }

    public String getKey() {
        return key;
    }

    public String getName() {
        return name;
    }

    private static HashMap<String, RechargeTypeEnum> keyMap;

    public static RechargeTypeEnum getByKey(String key){
        if (keyMap == null) {
            HashMap<String, RechargeTypeEnum> map = new HashMap<>();
            for (RechargeTypeEnum value : RechargeTypeEnum.values()) {
                map.put(value.getKey(),value);
            }
            keyMap = map;
        }
        return keyMap.get(key);
    }

    public static RechargeTypeEnum getByKey(String key,RechargeTypeEnum recordType){
        RechargeTypeEnum type = getByKey(key);
        return type == null ? recordType : type;
    }
}
